use std::path::PathBuf;
use cargo::execute_main_without_stdin;
-use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult};
+use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult, ChainError};
#[derive(RustcDecodable)]
pub struct Flags {
}))
}
};
- try!(util::process(&command).args(&args[1..]).exec());
+ try!(util::process(&command).args(&args[1..]).exec().chain_error(|| {
+ human(format!("third party subcommand `{}` exited unsuccessfully", command_exe))
+ }));
Ok(())
}
assert!(p.release_bin("foo").c_exists());
assert_that(cargo_home(), has_installed_exe("foo"));
});
+
+test!(reports_unsuccessful_subcommand_result {
+ Package::new("cargo-fail", "1.0.0")
+ .file("src/main.rs", r#"
+ fn main() {
+ panic!();
+ }
+ "#)
+ .publish();
+ assert_that(cargo_process("install").arg("cargo-fail"),
+ execs().with_status(0));
+ assert_that(cargo_process("--list"),
+ execs().with_status(0).with_stdout_contains(" fail\n"));
+ assert_that(cargo_process("fail"),
+ execs().with_status(101).with_stderr_contains("\
+thread '<main>' panicked at 'explicit panic', [..]
+").with_stderr_contains("\
+third party subcommand `cargo-fail[..]` exited unsuccessfully
+
+To learn more, run the command again with --verbose.
+"));
+});